﻿#region Using Statements
using System;
using System.Diagnostics;
#endregion

namespace DirectZZT.Shared.Input
{
    /// <summary>
    /// Defines an input command, that can be issued from the game.
    /// </summary>
    [DebuggerDisplay("Name = {Name}")]
    public struct InputCommand : IEquatable<InputCommand>
    {
        #region Properties

        /// <summary>
        /// Gets the name of the command.
        /// </summary>
        public string Name { get; private set; }
        /// <summary>
        /// Gets/sets the display name of the command.
        /// </summary>
        public string DisplayName { get; set; }
        /// <summary>
        /// Gets/sets whether or not this is a valued command (a command that takes values, like axis etc.).
        /// </summary>
        public bool IsValued { get; set; }
        /// <summary>
        /// Gets the devices that can handle this command.
        /// </summary>
        public InputManagerDevices Devices { get; private set; }
        /// <summary>
        /// Gets the flags of this command.
        /// </summary>
        public InputCommandFlags Flags { get; private set; }

        #endregion

        #region Constructor

        /// <summary>
        /// Initializes a new instance of the InputCommand struct.
        /// </summary>
        /// <param name="name">The name of the command.</param>
        /// <param name="devices">The devices that can handle this command.</param>
        /// <exception cref="System.ArgumentException">Parameter <paramref name="name"/> was null or empty.</exception>
        /// <param name="flags">The flags of this command.</param>
        public InputCommand(string name, InputManagerDevices devices, InputCommandFlags flags)
            : this()
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException("Null or empty", "name");
            }
            this.Name = name;
            this.Devices = devices;
            this.Flags = flags;
        }

        #endregion

        #region IEquatable<InputCommand> Members

        /// <summary>
        /// Returns whether or not this <see cref="InputCommand"/> instance is equal to another one.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool Equals(InputCommand other)
        {
            return string.Equals(Name, other.Name, StringComparison.InvariantCultureIgnoreCase);
        }

        #endregion
    }
}
